package com.tiantianyuegou.cash;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.tiantianyuegou.enums.PayType;
import com.tiantianyuegou.model.CashInfo;

/**
 * 账户余额提现
 */
public class AccountCash extends AbstractCash {

    private int orderType;
    OnCashListner listener;
    public AccountCash(int orderType) {
        this.orderType = orderType;
    }

    @Override
    public void cash(Activity activity, final CashInfo cashInfo, OnCashListner listener) {
        this.listener=listener;
        CashPasswordDialogFragment fragment = new CashPasswordDialogFragment();
        Bundle args = new Bundle();
        args.putString(CashPasswordDialogFragment.EXTRA_CASHMONEY, cashInfo.getCashMoney());
        args.putString(CashPasswordDialogFragment.EXTRA_DESP, cashInfo.getDesp());
        args.putString(CashPasswordDialogFragment.EXTRA_TBID, cashInfo.getTbId());
        fragment.setArguments(args);
        fragment.show(((FragmentActivity) activity).getSupportFragmentManager(), "");
        fragment.setPayResultListener(new CashPasswordDialogFragment.iPayResultListener() {
            @Override
            public void paySuccess() {
                callCashSuccess("success");
            }
        });
    }

    @Override
    protected void callCashSuccess(String result) {
        super.callCashSuccess(result);
        listener.onCashSuccessed(PayType.BLANACE,result);
    }

    @Override
    public boolean isInit() {
        return true;
    }


}
